﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="List.aspx.vb" Inherits="Testing.List" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Button ID="btn_AddNew" runat="server" Text="Add New Book" />
    <br />
    <fieldset style="background-color: #C0C0C0">
    <legend>Top 2 Best Rating Books</legend>

        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DBConnString %>" 
            ProviderName="<%$ ConnectionStrings:DBConnString.ProviderName %>" 
            SelectCommand="SELECT TOP 2 AvgBR, B_Name,B_Price, B_Picture, ID FROM [Query_ BooksAvgRating]">
        </asp:SqlDataSource>
        <br />

        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource2">
        <ItemTemplate>
           <a href=Details.aspx?ID=<%# Eval("ID")%>> <img alt="Name: <%# Eval("B_Name")%>" src="<%# Eval("B_Picture")%>"  width="100" height="150"/></a>
        </ItemTemplate>
        </asp:Repeater>
    </fieldset>
    <fieldset>
        <legend>List of Books</legend>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" 
            DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
            Width="100%" AllowSorting="True" PageSize="4">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" 
                HorizontalAlign="Left" />
            <Columns>
                <asp:ImageField DataAlternateTextField="B_Name" DataImageUrlField="B_Picture">
                    <ControlStyle Height="200px" Width="150px" />
                </asp:ImageField>
                <asp:HyperLinkField DataNavigateUrlFields="ID" 
                    DataNavigateUrlFormatString="Details.aspx?ID={0}" DataTextField="B_Name" 
                    HeaderText="Book Name" SortExpression="B_Name" />
                <asp:BoundField DataField="B_Author" HeaderText="Author" 
                    SortExpression="B_Author" />
                <asp:BoundField DataField="B_ISBN" HeaderText="ISBN" SortExpression="B_ISBN" />
                <asp:BoundField DataField="B_Price" DataFormatString="{0:c}" 
                    HeaderText="Price" SortExpression="B_Price" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DBConnString %>" 
            ProviderName="<%$ ConnectionStrings:DBConnString.ProviderName %>" 
            SelectCommand="SELECT * FROM [Books] ORDER BY [ID] DESC">
        </asp:SqlDataSource>
    </fieldset>
</asp:Content>
